$import("meta.metaHelper");
/**
 * 备注
 * */
function initMarkPanel(region){
	var form = new Ext.FormPanel({
        frame: true,
        layout: {
            type:'vbox',
            padding:'5',
            align:'stretch'
        },
        defaults:{margins:'0 0 5 0'},
        id:'markForm',
        closable:true,
        region:region,
        waitMsgTarget: true,
        tbar:[{
            text:'提交',
            iconCls:"icon-submit",
            handler:function(){
           	 var form=Ext.getCmp('markForm').getForm();
            	var markCtrl=form.findField("mark");
            	var mark=markCtrl.getValue();
            	if(mark!=markCtrl.originalValue){
            		 metaHelper.saveMark(metaId,sid,mark,function(data){
            			 if(!data["success"])return Ext.Msg.alert('提示','保存出错');
                		 if(data){
                			 return Ext.Msg.alert('提示','保存成功');
                		 }
                	 });
            	}else{
            		return Ext.Msg.alert('提示','没有修改,无需提交');
            	}
            }},{
            	text:'刷新',
            	iconCls:"icon-reload",
            	handler:function(){
            		form["loadData"]();
            	}
            }],
        items: [
                {
                	name:'mark',
                	flex:1,
                	align:'stretchmax',
                	xtype:'htmleditor'
                }]
 });
	form["loadData"]=function(){
		metaHelper.getMark(metaId,sid,function(data){
			if(!data["success"])return Ext.Msg.alert('提示','加载配置数据出错');
			var ctrl=form.getForm().findField("mark");
			ctrl.setValue(data["data"]);
			ctrl.originalValue=ctrl.getValue();
		});
	};
	return form;
}
Ext.onReady(function(){
	Ext.QuickTips.init();
	var form=initMarkPanel('center');
	new Ext.Viewport({
        width: 900,
        layout:'border',
        height: document.documentElement.clientHeight-10,
        renderTo: 'body',
        items:form
	});
	form["loadData"]();
});
